package com.lanyun.carworld.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanyun.carworld.model.dto.user.PostCreateRequest;
import com.lanyun.carworld.model.entity.Post;
import com.lanyun.carworld.mapper.PostMapper;
import com.lanyun.carworld.service.PostService;
import org.springframework.stereotype.Service;

/**
* @author 29074
* @description 针对表【post(帖子)】的数据库操作Service实现
* @createDate 2024-06-13 14:47:55
*/
@Service
public class PostServiceImpl extends ServiceImpl<PostMapper, Post>
    implements PostService{


    /**
     * 创建帖子
     * @return
     */
    @Override
    public Long create(Long userId, PostCreateRequest request) {
        String title = request.getTitle();

        String content = request.getContent();

        Post post = new Post();

        post.setUserId(userId);
        post.setTitle(title);
        post.setContent(content);

        this.save(post);
        Long id = post.getId();

        return post.getId();
    }
}




